Berkeley CS 61C Lecture 12

Here are some notes and corrections on this lecture:

Each note begins with a time; "ca." in front of a time means that it is approximate.

This lecture opens up a whole can of worms that I didn't even know exists: sign-extend vs. zero-extend. The book does not have ori in its MIPS-lite instruction set, so this is the first time I've had this issue crop up. The problem is that the immediate field in I-format instructions is 16 bits, but it goes to an ALU input, which is 32 bits. They solve the problem by filling in the top 16 bits to make 32. This is complicated by the fact that some instructions (loads, stores, arithmetic operations) treat the 16-bit immediate value as signed, and some (logical operations) treat it as unsigned. The former use sign-extend; they fill in 16 copies of the leftmost bit (the sign bit) of the 16-bit immediate field, thus yielding a signed 32-bit value representing the same number as the signed 16-bit value in the immediate field. The latter treat it as unsigned and therefore use zero-extend; they just fill in the top 16 bits with zeroes.

30:00 ff. -- PCExt is his name for what we call Branch Offset. When we add it to PC+4, we get the Branch Target.

32:00 -- The book's datapath diagrams are much prettier.

1.08 -- He says complete, but the jump instruction is not there.